package tools

import "time"

const SECS_IN_HOUR = 60 * 60
const SECS_IN_DAY = 24 * SECS_IN_HOUR

func YeasterdayTime() int64 {
	date := time.Unix(time.Now().AddDate(0, 0, -1).Unix(), 0).Format("2006-01-02")
	datetime, _ := time.Parse("2006-01-02 15:04:05", date)
	return datetime.Unix()
}

func NowTimeSecs() int64 {
	return time.Now().Unix()
}

func TodayTime() int64 {
	date := time.Now().Format("2006-01-02")
	datetime, _ := time.ParseInLocation("2006-01-02", date, time.Local)
	return datetime.Local().Unix()
}

func DayStart(d string) int64 {
	dd, _ := time.Parse("2006-01-02", d)
	//date := time.Unix(dd.AddDate(0, 0, -1).Unix(), 0).Format("2006-01-02") + " 16:00:00"
	//datetime, _ := time.Parse("2006-01-02 15:04:05", date)
	return dd.Unix()
}

func DayEnd(d string) int64 {
	//date := d + " 16:00:00"
	datetime, _ := time.Parse("2006-01-02", d)
	return datetime.Unix()
}
